import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';
import vueJsx from "@vitejs/plugin-vue-jsx";
/**
 * 低版本浏览器支持
 */
import legacy from '@vitejs/plugin-legacy'


const lastBuildVersion = function () {
  let date = new Date();
  let year = date.getFullYear() + "";
  let month = date.getMonth() + 1 + '';
  let day = date.getDate() + '';
  let hour = date.getHours() + '';
  let minutes = date.getMinutes() + "";
  let second = date.getSeconds() + '';
  return `${year.substring(2)}.${month.padStart(2, '0')}.${day.padStart(2, '0')}.${hour.padStart(2, '0')}.${minutes.padStart(2, '0')}.${second.padStart(2, '0')}`
}


const __APP_INFO__ = {
  lastBuildVersion: lastBuildVersion(),
};



// https://vitejs.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      // 导入scss预编译程序
      scss: {
        additionalData: `@use "@/assets/index.scss" as *;`,
      },
    },
  },
  
  publicPath: "./",
  publicDir: "public",
  // base: "/biaozhugongju", //项目根文件目录 
  // base: "/", //项目根文件目录 

  plugins: [
    vue(),
    vueJsx(),
	
	legacy({
	  targets: ["Chrome 64"],
	  modernPolyfills: true
	}),
    // eslint()
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    }
  },
  define: {
    __APP_INFO__: JSON.stringify(__APP_INFO__),
  },
})
